var t = require("../../../@babel/runtime/helpers/defineProperty"), a = getApp(), e = require("../../../utils/themeSkin/skinBehavior");

Page({
    behaviors: [ e ],
    data: {
        transfer_point: 0,
        loading: !1,
        credit1: "",
        point_name: "",
        integral_name: "",
        transfer_point_ratio: 0,
        transfer_integral_ratio: 0,
        practical_num: 0,
        loveByMember: 0,
        transfer_integral: 0,
        transfer_integral_love: 0,
        exchange_num: 0
    },
    onLoad: function(t) {
        t.loveByMember && this.setData({
            loveByMember: t.loveByMember
        });
        var a = wx.getStorageSync("yz_basic_info");
        this.setData({
            love: a.love,
            point: a.point
        }), console.log(this.data.loveByMember), this.data.loveByMember ? this.getLoveData() : this.getData();
    },
    onChange: function(t) {
        if (this.setData({
            transfer_point: t.detail
        }), t.detail > 0) {
            var a = 0;
            a = this.data.loveByMember ? (this.data.transfer_integral_love / this.data.transfer_integral).toFixed(4) * t.detail : (this.data.transfer_integral_ratio / this.data.transfer_point_ratio).toFixed(4) * t.detail, 
            console.log(a, "ddddddd"), this.setData({
                practical_num: a.toFixed(2)
            });
        }
    },
    onReady: function() {},
    getLoveData: function() {
        var t = this, e = this, n = a.getNetAddresss("finance.point-page.index");
        a._getNetWork({
            url: n,
            success: function(a) {
                var n, r = a.data;
                1 == r.result ? (e.setData({
                    credit1: r.data.credit1,
                    transfer: r.data.transfer,
                    transfer_integral: r.data.transfer_integral,
                    transfer_integral_love: r.data.transfer_integral_love
                }), t.data.loveByMember && (n = "".concat(t.data.point, "转化").concat(t.data.love)), 
                t.data.loveByMember, wx.setNavigationBarTitle({
                    title: n
                }), wx.setNavigationBarColor({
                    frontColor: "#ffffff",
                    backgroundColor: t.data.themeBaseColor,
                    animation: {
                        duration: 400,
                        timingFunc: "easeIn"
                    }
                })) : wx.showToast({
                    icon: "none",
                    title: r.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getData: function() {
        var t = this;
        a._postNetWork({
            url: a.getNetAddresss("finance.point-transfer-integral.page-per"),
            success: function(a) {
                if (a.data.result) {
                    var e = a.data.data;
                    t.setData({
                        credit1: e.credit1,
                        point_name: e.point_name,
                        integral_name: e.integral_name,
                        transfer_point_ratio: e.transfer_point_ratio,
                        transfer_integral_ratio: e.transfer_integral_ratio
                    });
                    var n = e.point_name + "转化" + e.integral_name;
                    t.data.loveByMember && (n = "".concat(e.point_name, "转化").concat(t.data.love)), 
                    t.data.loveByMember, wx.setNavigationBarTitle({
                        title: n
                    }), wx.setNavigationBarColor({
                        frontColor: "#ffffff",
                        backgroundColor: t.data.themeBaseColor,
                        animation: {
                            duration: 400,
                            timingFunc: "easeIn"
                        }
                    });
                }
            }
        });
    },
    submit: function() {
        var e = this;
        this.setData({
            loading: !0
        });
        var n = {};
        console.log(this.data.loveByMember), this.data.loveByMember ? (n.transfer_point = parseFloat(this.data.transfer_point), 
        n.urlApi = "finance.point-exchange-love.index", n.attribute = "exchange_num") : (n.transfer_point = this.data.transfer_point, 
        n.urlApi = "finance.point-transfer-integral.index", n.attribute = "transfer_point");
        var r = n.attribute, i = t({}, r, n.transfer_point);
        a._postNetWork({
            url: a.getNetAddresss(n.urlApi),
            data: i,
            success: function(t) {
                if (e.setData({
                    loading: !1
                }), t.data.result) {
                    a.tips(t.data.msg), e.setData({
                        transfer_point: "",
                        practical_num: 0
                    }), e.data.loveByMember ? e.getLoveData() : e.getData();
                    var n = getCurrentPages();
                    n[n.length - 2].onLoad(), setTimeout(function() {
                        wx.navigateBack({
                            data: 1
                        });
                    }, 1e3);
                } else a.tips(t.data.msg);
            }
        });
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {}
});